﻿@using X.PagedList;
@using X.PagedList.Mvc.Core;
@using X.PagedList.Mvc.Common;
@using FwProject.Restaurant;
@using FwProject.Restaurant.Dto
@model IPagedList<DepositListDto>
@{
    Layout = null;
    //double SumDeposit = 0.00;
    int count = 0;
    int x = 0;
    if (Model.Count > 0)
    {
        if (Model.PageNumber != 1)
        {

            x = (Model.PageNumber - 1) * Model.PageSize;
        }
    }
}
<div id="table_print">

    <table class="table table-bordered table-hover table-rowselected">
        <thead>
            <tr>
                <th style="width:45px">序号</th>
                <th>餐厅名称</th>
                <th>状态</th>
                <th>押金编号</th>
                <th>类型</th>
                <th>日期</th>
                <th>金额（￥）</th>
                <th style="width:200px;">操作</th>
            </tr>
        </thead>
        <tbody>
            @if (Model.Count == 0)
            {
                <tr><td colspan="8">暂无数据</td></tr>
            }
            else
            {
                foreach (var item in Model)
                {
                    x++;
                    count = item.DepositList.Count;
                    int i = 0;
                    foreach (var chilitem in item.DepositList)
                    {
                        <tr>
                            @if (i == 0)
                            {
                                <td rowspan="@count">@x</td>
                                <td rowspan="@count">@item.RestaurantName</td>
                                if (chilitem.DepositStatus == DepositStatus.未审核)
                                {
                                    <td style="color:red">@chilitem.DepositStatus</td>
                                }
                                else
                                {
                                    <td style="color:green">@chilitem.DepositStatus</td>
                                }
                                <td><a href="javascript:top.window.openTab(1023,'押金单[@chilitem.CreationNumber]','@Url.Action("Examine",new { id=chilitem.Id})')">@chilitem.CreationNumber</a></td>
                                <td>@chilitem.DepositType</td>
                                <td>@chilitem.CreationTime.ToString("yyyy-MM-dd")</td>
                                <td>@chilitem.Money</td>
                                if (chilitem.DepositStatus == DepositStatus.未审核)
                                {
                                    <td>
                                        <a class="btn btn-default btn-xs">打印收据</a>
                                    </td>
                                }
                                else
                                {
                                    <td>
                                        <a class="btn btn-info btn-xs" href="@Url.Action("CollectDepositPrint",new { id=chilitem.Id})" target="view_window">打印收据</a>
                                    </td>
                                }


                            }
                            else
                            {
                                if (chilitem.DepositStatus == DepositStatus.未审核)
                                {
                                    <td style="color:red">@chilitem.DepositStatus</td>
                                }
                                else
                                {
                                    <td style="color:green">@chilitem.DepositStatus</td>
                                }
                                <td><a href="/Deposit/Examine?id=@chilitem.Id">@chilitem.CreationNumber</a></td>
                                <td>@chilitem.DepositType</td>
                                <td>@chilitem.CreationTime.ToString("yyyy-MM-dd")</td>
                                <td>@chilitem.Money</td>
                                if (chilitem.DepositStatus == DepositStatus.未审核)
                                {
                                    <td>
                                        <a class="btn btn-default btn-xs">打印收据</a>
                                    </td>
                                }
                                else
                                {
                                    <td>
                                        <a class="btn btn-info btn-xs" href="@Url.Action("CollectDepositPrint",new { id=chilitem.Id})" target="view_window">打印收据</a>
                                    </td>
                                }

                            }
                        </tr>
                        i++;
                    }
                }
                @*<tr class="footer" style="color:red">
                        <td colspan="4">合计（￥）</td>
                        <td>@SumDeposit</td>
                    </tr>*@
            }
        </tbody>
    </table>
</div>
<div class="row pagedinfo">
    <div class="col-sm-5">
        共 @Model.TotalItemCount 条，@Model.PageSize 条/页 当前第 @Model.PageNumber/@Model.PageCount 页
    </div>
    <div class="col-sm-7">
        @Html.PagedListPager(Model, page => Url.Action("CollectAndReturnDeposit", new { pageIdx = page, RestaurantName = Context.Request.Query["RestaurantName"], Type = Context.Request.Query["Type"], beginTime = Context.Request.Query["beginTime"], endTime = Context.Request.Query["endTime"] }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions() { AllowCache = false, HttpMethod = "Get", UpdateTargetId = "data_list", OnSuccess = "AjaxSuccessCallback", OnBegin = "AjaxBegin" }))
    </div>
</div>
